package com.share.common.utils;

import org.slf4j.MDC;

public class MdcUtil {
    private final static String TRACE_ID = "X-B3-TraceId";
    private final static String SPAN_ID = "X-B3-SpanId";
    private final static String EXPORT = "X-B3-Export";

    public static String initTraceId() {
        String traceId = "ST" + System.currentTimeMillis();
        setTraceId(traceId);
        return traceId;
    }

    public static void setTraceId(String traceId) {
        MDC.put(TRACE_ID, traceId);
    }

    public static void setSpanId(String spanId) {
        MDC.put(SPAN_ID, spanId);
    }

    public static void setExport(String export) {
        MDC.put(EXPORT, export);
    }
}
